feat: weighted Reciprocal Rank Fusion for recall#1631
Open
dcbouius wants to merge 3 commits into
Open
Conversation
Add per-strategy weights to RRF fusion, allowing tuning of how much each retrieval method (semantic, BM25, graph, temporal) influences the merged ranking. Weights follow the hierarchical config model: server defaults via env vars (HINDSIGHT_API_RECALL_WEIGHT_*), overridable per-bank via config API, and per-request via the retrieval_weights field on recall. Default weights are all 1.0, preserving existing behavior exactly.
Contributor
|
@dcbouius I am not sure this is the best solution to making graph results higher weight. We already have "boosters" for things like recency that work after the rerank. We can just add a graph boost. Its is simpler and guaranteed to move up the graph results. Doing it during the fusion increases the chances that the graph results will win, but the rerank could still decided otherwise. |
… recall_async The weight resolution logic referenced budget_config_dict which only exists in recall_async scope, not in _search_with_retries. Move the resolution to recall_async and pass the computed rrf_weights through.
Add retrieval_weights field to generated Go, Python, and TypeScript clients to match the new recall API parameter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
API
New optional
retrieval_weightsfield on the recall request:{ "query": "What happened at the meeting?", "retrieval_weights": { "semantic": 1.0, "bm25": 1.0, "graph": 2.0, "temporal": 1.0 } }Keys:
semantic,bm25,graph,temporal. Values are multipliers (1.0 = default, 2.0 = double influence, 0.0 = disabled). Omitted keys default to bank/server config.Configuration
Server-level defaults via env vars:
HINDSIGHT_API_RECALL_WEIGHT_SEMANTIC(default: 1.0)HINDSIGHT_API_RECALL_WEIGHT_BM25(default: 1.0)HINDSIGHT_API_RECALL_WEIGHT_GRAPH(default: 1.0)HINDSIGHT_API_RECALL_WEIGHT_TEMPORAL(default: 1.0)All four are in
_CONFIGURABLE_FIELDS, so they can be overridden per-bank via the config API.Changes
fusion.py—reciprocal_rank_fusion()accepts optionalweightsdict; formula becomesw_i / (k + rank)config.py— 4 new hierarchical config fields with env var + default supporthttp.py—RecallRequest.retrieval_weightsfieldmemory_engine.py— Merges config + request weights, passes to RRFinterface.py—retrieval_weightsparam on abstractrecall_asyncTest plan